<blockquote class="layui-elem-quote">{$title}</blockquote>
<from class="layui-form">
    <div class="layui-inline" style="width:400px;">
        <input type="text" class="layui-input" name="keyword" autocomplete="off" placeholder="请输入栏目名称进行搜索，搜索以后不会保持树结构">
    </div>
    <button class="layui-btn" type="button" lay-submit lay-filter="menu_search" id="reloadBtn"><i class="layui-icon">&#xe615;</i> 搜索</button>
</from>
<table class="layui-hide" id="LAY_table_menu" lay-filter="menu"></table>
<script type="text/html" id="menu_name">
    {{ d.level_name  ? d.level_name + '&ensp;': '' }}{{ d.page_name }}
</script>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add">添加栏目</button>
    </div>
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon">&#xe642;</i>编辑&ensp;</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i>删除&ensp;</a>
</script>
<script>
    layui.use(['table'], function(){
        var table = layui.table,form = layui.form;
        form.render();
        //监听工具条
        table.on('tool(menu)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                layui_open("{:url('Systems/columnPageAdd')}",{page_id:data.page_id},data.page_name + " - 编辑栏目","60%","80%",table);
            }else if(obj.event === 'del'){
                layer.confirm('确定要删除 《'+data.page_name+'》 栏目？', {
                    skin: 'layui-layer-lan',
                    title:'删除',
                    btn: ['确定','取消'] //按钮
                }, function(){
                    post_sub("{:url('Systems/columnPageDel')}",{page_id:data.page_id},table);
                });

            }
        });
        //方法级渲染
        table.render({
            elem: '#LAY_table_menu'
            ,url: '{:url("Systems/columnPageSetup",["table"=>1])}'
            ,cellMinWidth: 80
            ,cols: [[
                {checkbox: true}
                ,{field:'page_id',title: 'ID',align:'center', width:80}
                ,{field:'page_name',title: '栏目名称',align:'left', minWidth:100,templet: '#menu_name'}
                ,{field:'sort',title: '排序',align:'left', minWidth:100}
                ,{field:'create_time',title: '添加时间',align:'left'}
                {empty name="SUBSTATIONS"},{field:'substation_name',title: '分站',align:'left'}{/empty}
                ,{title:'操作', toolbar: '#barDemo',align:'center'}
            ]]
            ,id: 'testReload'
            ,page: false
            ,toolbar:"#toolbarDemo"
            ,defaultToolbar:{$defaultToolbar}
            ,done:function () {

                //强制去掉横向滚动条
                $(".layui-table-body.layui-table-main").css("overflow-x","inherit");
            }
        });

        //头部工具条监听事件
        table.on('toolbar(menu)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'add':
                    layui_open("{:url('Systems/columnPageAdd')}",{},"添加栏目","60%","80%",table);
                    break;
            };
        });

        //搜索重载表格
        form.on('submit(menu_search)', function(data){
            table.reload('testReload', {
                where: data.field,
            });
            return false;
        });

        $(".layui-form").keydown(function(event){
            var keycode = (event.keyCode ? event.keyCode : event.which);
            if(keycode == '13'){
                //回车触发
                $('#reloadBtn').trigger('click');
            }
        });
    });


</script>
</body>
</html>